Skip to content

feat: read a second document beside the one being translated - #102

Merged
xAlcahest merged 5 commits into
mainfrom
source-column
Sep 6, 2026
Merged

feat: read a second document beside the one being translated#102
xAlcahest merged 5 commits into
mainfrom
source-column

Conversation

@xAlcahest

Copy link
Copy Markdown
Owner

Summary

The first slice of M2.6: the document a translator reads from is opened beside the one being written, and the grid draws it as one more column, aligned row for row. SubtitleState now holds two sessions rather than one, and they are two slots and not one with a flag on purpose: no edit can reach the source by taking a wrong branch, because every mutating command asks for slot() and nothing anywhere asks for source_slot() and then writes. The source is never edited, never saved and never backed up, so it has no dirty state to guard.

The two items that need it, Open source subtitle and Close source subtitle, are drawn on File whether or not they can run, and greyed by the same rule everything else greys by. A source is read beside a target, so the open greys until a target is open; the close greys until a source is.

A defect in the E2E suite is filed here rather than fixed, because fixing it means guessing. One check in video-aspect.spec.js fails on the CI runner and never on this machine, and it has done so since before this branch: the evidence it already collects rules out a logged refusal and a video error event, and what is left has not been proven. It is BACKLOG N40, and the first change is the one in this PR: the check now records which line of the status bar spoke, so the next failure names its cause instead of leaving it to be worked out from the sentence.

Changes

  • src-tauri/src/subtitle/mod.rs: SubtitleState holds a second session, with subtitle_open_source and subtitle_close_source over the same open_session and close_session the target uses.
  • src-tauri/src/lib.rs: the two commands registered.
  • src/hooks/useSourceFile.ts: the document being read from, with no revision, no patch and no undo stack, because nothing here writes.
  • src/components/CueList.tsx: the source column, drawn while a source is open and blank on a row the source does not reach.
  • src/components/StatusBar.tsx: the bar names the document being read, in the shape it already names the target in.
  • src/App.tsx: the two File commands, the hook, and the grid and the bar wired to it.
  • src/i18n/en.ts: the column's word, the two menu items and the bar's sentence.
  • src/styles/grid.css: the column, sharing the width evenly with the target's text and drawn quieter.
  • src/styles/shell.css: the bar's own line for the source.
  • e2e/specs/source-column.spec.js: five checks over S1's criteria, from the greying to the source file's bytes.
  • e2e/specs/command-registry.spec.js: the two new commands in the declared list, the File menu and the greying table.
  • e2e/specs/video-aspect.spec.js: the alerts are recorded with the class each carries. See N40.
  • e2e/wdio.conf.js: the count the anti-zero guard holds.
  • BACKLOG.md: N40, the check that fails on CI and not here, with what its own evidence rules out.

How to verify it by using the app

  1. Open fixtures/subtitles/srt/clean/basic-lf.srt. The grid shows three lines and no Source column.
  2. Open the File menu. Open source subtitle is alive now that there is a target; Close source subtitle is greyed, because none is open.
  3. Choose Open source subtitle and pick fixtures/subtitles/srt/clean/starts-at-zero-short.srt. A Source column appears at the right of the grid: row 1 says "Bring the nets in.", row 2 says the gulls line, and row 3 is blank, because that file has only two lines.
  4. The status bar now says Source: SRT · 2 cues · LF beside what it says about the target.
  5. Type over the first line in the current line's box and save. The target takes the edit; the file you opened as the source is untouched, and no backup of it is made.
  6. File, Close source subtitle. The column goes and the target stays exactly where it was, with the line you wrote.
  7. Choose Open source subtitle again and pick fixtures/subtitles/srt/malformed/missing-arrow.srt. The status bar says why it could not be read, and no column is left behind half filled.

Verified on Linux: full gate green step by step, and the battery green at 34 spec files of 34 with 283 checks. Two mutations each reddened its own check first, the column reading the target instead of the source, and a close that leaves the rows behind.

@xAlcahest
xAlcahest merged commit e60dea8 into main Sep 6, 2026
14 checks passed
@xAlcahest
xAlcahest deleted the source-column branch September 6, 2026 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant